import java.util.Scanner;

public class equals {
    public static void main(String[] args) {
        String s1 = new String("abc");//在堆上开辟空间,不存在复用
        String s2 = "abc";//在串池开辟空间,存在复用
        System.out.println(s1 == s2);//比较地址值

        String s3 = new String("123");
        String s4 = new String("123");
        System.out.println(s3 == s4);

        String s5 = "TWF";
        String s6 = "TWF";
        System.out.println(s5 == s6);

        boolean a = s1.equals(s2);//比较字符串对象里面的内容
        System.out.println(a);

        String s7 = "twf";
        boolean b = s6.equalsIgnoreCase(s7);//比较字符串对象里面的内容,比较时忽略大小写
        System.out.println(b);

        Scanner sc = new Scanner(System.in);
        String s8 = sc.next();//键盘录入的字符串是new出来的,即在堆上开辟空间
        String s9 = "123";
        System.out.println(s8 == s9);
    }
}
